<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Models\User;
use App\Http\Requests\Auth\AuthRequest;
use Illuminate\Http\Request;
use Auth;

class AuthController extends Controller
{
    function login(AuthRequest $request) {
        if (!$token = Auth::guard('api')->attempt($request->all())) {
            return $this->error('用户名或密码错误！', null);
        }

        return $this->success('登录成功', [
            'access_token' => $token,
            'token_type' => 'Bearer',
            'expires_in' => \Auth::guard('api')->factory()->getTTL() * 60
        ]);
    }
}
